<template>
  <div style="height: 440px;">
    <div class="fontWeight biaoti">完税统计</div>
    <div class="flex flex-end mt20 mb55">
      <el-select style="width:150px" v-model="companyAdminId" class="mr10" placeholder="请选择客户企业" clearable filterable>
        <el-option
          v-for="dict in clientEnterpriseOptions"
          :key="dict.id"
          :label="dict.companyName"
          :value="dict.id"
        />
      </el-select>
      <el-date-picker
      style="width:135px"
      v-model="value1"
      type="date"
      placeholder="开始日期"
      :picker-options="pickerOptions"
      >
      </el-date-picker>
      <span style="padding:7px 5px">-</span>
      <el-date-picker
      style="width:135px"
      v-model="value2"
      type="date"
      placeholder="结束日期"
      :picker-options="pickerOptions"
      >
      </el-date-picker>
    </div>
    <div style="height:200px;width:100%" id="myChart_pie"></div>
    <div class="flex justify-content">
      <div>
        <p class="p1">总申报额（万元）</p>
        <count-to :start-val="0" :end-val="36524100" :duration="2600" class="p2" />
      </div>
      <div>
        <p class="p1">完税金额（万元）</p>
        <count-to :start-val="0" :end-val="36000000" :duration="3000" class="p2" />
      </div>
      <div>
        <p class="p1">失败金额（万元）</p>
        <count-to :start-val="0" :end-val="524100" :duration="3200" class="p2" />
      </div>
      <div>
        <p class="p1">未申报（万元）</p>
        <count-to :start-val="0" :end-val="524100" :duration="3600" class="p2" />
      </div>
    </div>
    <!-- <div :class="className" :style="{height:height,width:width}" /> -->
    
    </div>
</template>

<script>
import echarts from 'echarts'
import 'echarts-liquidfill/src/liquidFill.js';
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'
import CountTo from 'vue-count-to'

export default {
  components: {
    CountTo
  },
  mixins: [resize],
  // props: {
  //   className: {
  //     type: String,
  //     default: 'chart'
  //   },
  //   width: {
  //     type: String,
  //     default: '100%'
  //   },
  //   height: {
  //     type: String,
  //     default: '300px'
  //   }
  // },
  data() {
    return {
      chart: null,
      pickerOptions: {
            disabledDate(time) {
                let curDate = (new Date()).getTime();
                let twelve = 365 * 24 * 3600 * 1000;
                let twelveMonths = curDate - twelve;
                return time.getTime() > Date.now() || time.getTime() < twelveMonths;
            }
      },
      value1: '',
      value2: '',
      clientEnterpriseOptions: [], // 所有客户企业下拉列表信息数据字典数据
      companyAdminId: undefined,
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  created() {
    this.getClientEnterprise().then(response => {
      this.clientEnterpriseOptions = response.data;
    });
  },
  methods: {
    initChart() {
      //this.chart = echarts.init(this.$el, 'macarons')
      this.chart = echarts.init(document.getElementById('myChart_pie'), 'macarons')
      this.chart.setOption({
        title:{
            text: "完税金额",
            left: "center",
            bottom:"bottom",
            bottom:'10%',
            textStyle: {
              color: '#333',
              fontSize: '14'
            }
        },
        series: [{
            type: 'liquidFill',
            data: [0.6],
            color: ['#045aff'],
            itemStyle: {         //普通样式
                opacity: 0.6
            },
            emphasis: {
                itemStyle: {     //悬停样式
                    opacity: 0.9
                }
            },
            label: {
              normal: {
                  textStyle: {
                      fontSize: 24, //字体大小
                      fontWeight:'bold',
                  }
              }
            },
            outline: {
                show: false //是否显示轮廓 布尔值
            },
        }],
        
        // tooltip: {
        //   trigger: 'item',
        //   formatter: '{a} <br/>{b} : {c} ({d}%)'
        // },
        // legend: {
        //   left: 'center',
        //   bottom: '10',
        //   data: ['Industries', 'Technology', 'Forex', 'Gold', 'Forecasts']
        // },
        // series: [
        //   {
        //     name: 'WEEKLY WRITE ARTICLES',
        //     type: 'pie',
        //     roseType: 'radius',
        //     radius: [15, 95],
        //     center: ['50%', '38%'],
        //     data: [
        //       { value: 320, name: 'Industries' },
        //       { value: 240, name: 'Technology' },
        //       { value: 149, name: 'Forex' },
        //       { value: 100, name: 'Gold' },
        //       { value: 59, name: 'Forecasts' }
        //     ],
        //     animationEasing: 'cubicInOut',
        //     animationDuration: 2600
        //   }
        // ]
      })
    }
  }
}
</script>
<style scoped lang="scss">
    p.p1{
      font-size: 14px;
      color: #333;
    }
    .p2{
      font-size: 16px;
      color: #045aff;
      font-weight: bold;
    }
  </style>